﻿
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>生产工艺</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>

</head>
<body>
    <ul lay-bar="disabled" class="mWebBanner">
        <li class="layui-nav-item" style="float:left;">
            <button id="btn-update" type="button" name="btn_update" onclick="SaveFormData()" class="buttonCss">
                保存
            </button>
        </li>
        <li class="layui-nav-item" style="float:left;padding-left:20px">
            <button id="btn-sync" type="button" onclick="closeWin()" class="buttonCss">
                取消
            </button>
        </li>
    </ul>
    <div class="layui-card" style="margin-top:10px">
        <div class="layui-card-body ">
                 <form class="layui-form" id="mForm" >
                <div class="layui-form-item" style="margin-left:3%">
                    <div class="layui-input-inline" style="margin-left:2%">
                        <select id="gxCode" name="gxCode" lay-filter="gx">
                            <option value="">生产工序</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="margin-left:5%">
                        <select id="relationCode" name="relationCode" lay-filter="sp">
                        </select>
                        <input type="hidden" name="relationName" id="relationName">
                    </div>
                 
                  
               </div>
                <div class="layui-form-item">                  
                   <div class="layui-input-inline" style="margin-left:5%">
                        <input type="text" name="versionCode" placeholder="工艺版本号" class="layui-input" id="versionCode">
                     </div>
                </div>
                 <div class="layui-form-item">
                    <div class="layui-input-block" style="margin-left:5%">
                        <input type="text" name="memo" placeholder="备注说明" class="layui-input" id="versionCode">
                     </div>
                </div>
                <input type="hidden" id="keyCode" name="keyCode" />
               </form>
        </div>
    </div>
    <div class="layui-card" style="margin-top:6px">
        <div class="layui-card-body ">
            <form class="layui-form layui-col-space5" id="dForm">
            <div id="fDiv"></div>
            </form>
        </div>
    </div>
</body>
</html>
<script>
    var keyCode = "", proCode = "",gxCode="",version="";
    var proCode="";
    $(function () {
        keyCode = getUrlVariable("keyCode");
        proCode = getUrlVariable("reCode"); 
        gxCode = getUrlVariable("gxCode");
        version = getUrlVariable("version");
        //GetFormValue();
        CommonData("GX", "gxCode", gxCode);
        if (keyCode !=undefined && keyCode!="") {
            $("input[ name='versionCode']").val(version);
            gxProducts(gxCode,proCode);
            loadGyForm(gxCode, proCode);
           
       }
        layui.use('form', function () {
            var form = layui.form;
            form.on('select(gx)', function (data) {
                if (keyCode == undefined || keyCode == "") {
                    gxProducts(data.value);
                }
               
            });
              form.on('select(sp)', function (data) {
                   if (keyCode == undefined || keyCode == "") {
                    $("input[name='relationName']").val($("#relationCode option:selected").text());
                    gxCode = $('#gxCode').val();
                    proCode = $('#relationCode').val();
                    loadGyForm(gxCode, proCode);
                }
            
            });
 
        });
    })
    /**
     * 工序存货
     * **/
    function gxProducts(gxCode,dValue) {
        $("#relationCode").empty();
        $.ajax({
            url: "../ProductSet/gyProduct",
            data: { gxCode: gxCode },
            dataType: "json",
            type: "POST",
            success: function (rsl) {
                if (rsl.result) {
                    var datas = rsl.data;
                    $("#relationCode").append("<option value='' >选择存货</option>");
                    for (var i = 0; i < datas.length; i++) {
                        $("#relationCode").append("<option value='" + datas[i]["relationCode"] + "' >" + datas[i]["relationName"] + "</option>");
                    }
                    if (dValue != undefined && dValue != "") {
                        $("#relationCode option[value='" + dValue + "'] ").attr("selected", true);
                    }
                    layui.use('form', function () {
                        var form = layui.form;
                        form.render();
                    });
                }
            }
        });
    }

</script>

